package cn.edu.scau.cmi.ZengLinghong.chapter04;

public class Maxn {

	public static void main(String[] args) {
		long factorial = 1, sum = 0, n = 0;
		while(sum<=9876) {
			factorial*=++n;
			sum+=factorial;
			System.out.println(sum+" "+factorial);
		}
		System.out.println(n-1);
	}

}
